package com.sskj.mine;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.mine.http.HttpConfig;
import com.sskj.mine.presenter.BasePresenter;
import com.sskj.mine.ChangeNameActivity;


/**
 * @author Hey
 * Create at  2019/05/04
 */
class ChangeNamePresenter extends BasePresenter<ChangeNameActivity> {
    public void nickName(String nickname) {
        OkGo.<HttpData<Object>>post(HttpConfig.BASE_URL + HttpConfig.NICKNAME)
                .isMultipart(false)
                .params("nickname", nickname)
                .execute(new JsonCallBack<HttpData<Object>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<Object>> response) {
                        HttpData body = response.body();
                        if (body.status == HttpConfig.OK) {
                            ToastUtil.showShort(body.msg);
                            mView.updateUi();
                        }
                    }
                });
    }

}
